//
//  CCMMineViewCell.swift
//  CCMoney_swift
//
//  Created by JKHuang on 2018/11/27.
//  Copyright © 2018 JKHuang. All rights reserved.
//

import UIKit

class CCMMineHeadViewCell: UITableViewCell {

    fileprivate lazy var headView:UIImageView = {
        let image = UIImageView()
        image.layer.cornerRadius = 26
        image.contentMode = .scaleAspectFill
        image.clipsToBounds = true
        return image
    }()
    
    fileprivate lazy var nameLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 17)
        label.textColor = UIColor.white
        return label
    }()
    
    fileprivate lazy var rankLabel:UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 14)
        label.textColor = UIColor.hex(0xC7A582)
        return label
    }()
    
    fileprivate lazy var arrowButton:UIButton = {
        let button = UIButton()
        button.setImage(UIImage(named: "箭头_icon"), for: .normal)
        return button
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.contentView.backgroundColor = MainColor
        setUI()
        
        self.headView.image = UIImage(named: "头像_iocn")
        self.nameLabel.text = "大西瓜大西瓜"
        self.rankLabel.text = "等级名称"
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}

extension CCMMineHeadViewCell{
    
    fileprivate func setUI(){
        
        self.contentView.addSubview(self.headView)
        self.contentView.addSubview(self.nameLabel)
        self.contentView.addSubview(self.rankLabel)
        self.contentView.addSubview(self.arrowButton)
        
        self.headView.snp.makeConstraints { (make) in
            make.leading.equalTo(self.contentView).offset(15)
            make.centerY.equalTo(self.contentView)
            make.width.height.equalTo(71)
        }
        
        self.nameLabel.snp.makeConstraints { (make) in
            make.leading.equalTo(self.contentView).offset(102)
            make.top.equalTo(self.headView).offset(16)
            make.trailing.equalTo(self.contentView).offset(-25)
        }
        
        self.rankLabel.snp.makeConstraints { (make) in
            make.leading.equalTo(self.contentView).offset(102)
            make.top.equalTo(self.nameLabel.snp_bottomMargin).offset(15)
            make.trailing.equalTo(self.contentView).offset(-25)
        }
        
        self.arrowButton.snp.makeConstraints { (make) in
            make.trailing.equalTo(self.contentView).offset(-16)
            make.centerY.equalTo(self.contentView)
        }
        
    }
}
